
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id: SidekarEntity.java 197 2009-11-14 21:16:23Z archie.cobbs $
 */

package org.dellroad.sidekar.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Tags a class as a Sidekar entity class.
 *
 * <p>
 * When a class is annotated with this tag, all methods in this class and
 * all superclasses and superinterfaces will be checked for field annotations.
 * Superclasses will be checked for this annotation; the first one found will
 * indicate the entity's parent entity.
 */
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface SidekarEntity {

    /**
     * Specifies the name of the entity type in the Sidekar database that will
     * hold instances of this class. The name must be unique in the database
     * and must not contain any dot ('.') or at-sign ('@') characters.
     *
     * <p>
     * The default value is "", in which case the unqualified class name is used.
     */
    String name() default "";

    /**
     * Whether this entity is abstract. Abstract entites, like abstract Java
     * classes, can never be instantiated, and instances of abstract entities
     * will never exist in the database. Of course, instances of sub-entities
     * of an abstract entity may exist. Default value is false.
     *
     * <p>
     * The abstractness of the Java class to which this annotation applies is
     * <em>not</em> taken into consideration (user classes are usually abstract
     * anyway because Sidekar generates overridden method bodies at runtime).
     */
    boolean isAbstract() default false;

    /**
     * Indexes defined on this entity.
     */
    SidekarIndex[] indexes() default {};
}

